home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 41.zip
/
BS1 part 41
/
Lattice C v5.02 d4.adf
/
examples
/
debugger
/
dbstr.cpr
< prev
next >
Wrap
Text File
|
1988-11-07
|
1KB
|
48 lines
/*
DBSTR -- Dump memory as bytes for a given BSTR
DBSTR (<variable> | <address> | <range>)
>dbstr var /* Dumps the BSTR pointed to by var */
>dbstr 0x82034 /* Dumps the BSTR at location 0x002080d0 */
Note that a BSTR is an address shifted right 2 pointing to a buffer
with a preceeding length byte.
*/
parse arg expr
if (expr = '?') then
do
do i = 2 to 7
'd "' strip(sourceline(i),'T', "0a"x) '"'
end
exit(0)
end
options failat 3
options results
'd ' expr
stat = rc
val = strip(result,'T',"0a"x)
options
if (stat ~= 0) then
do
'd "Error: can''t find' expr '"'
exit(0)
end
val = strip(val)
if (~datatype(val,'x')) then
do
'd " ^------------should be an ''address''"'
exit(0)
end
bptr = d2c(c2d(x2c(val))*4,4)
bstr = import(offset(bptr,1),c2d(import(bptr,1)))
do forever
y = verify(bstr, '"'||'0a0d00'x,'m')
if y = 0 then leave
c = substr(bstr,y,1)
if c = '"' then
bstr = left(bstr,y-1)||'\'||'05'x||substr(bstr,y+1)
else
bstr = left(bstr,y-1)||'\\'||translate(c,'nr0','0a0d00'x)||substr(bstr,y+1)
end
bstr = translate(bstr, '"', '05'x)
'd "0x'||c2x(bptr)||': \"'||bstr||'\""'
exit(0)